#ifndef DRAWRECTROADITEM_H
#define DRAWRECTROADITEM_H

#include <QObject>
#include <QGraphicsRectItem>
#include <QDebug>
#include <QPainter>
#include <QGraphicsSceneMouseEvent>


class DrawRectRoadItem: public QObject, public QGraphicsRectItem
{
     Q_OBJECT

public:
    explicit DrawRectRoadItem(QObject *parent = nullptr);

    virtual ~DrawRectRoadItem()
    {
    }

    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = Q_NULLPTR) Q_DECL_OVERRIDE;

    void setPoint(const QPointF &point)
    {
        m_qPointEnd = point;

        if(m_bStart)
        {
            m_qPointBegin = point;
            m_bStart = false;
        }
    }

    QRectF getLink() const;

protected:
    void mousePressEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE;
    void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE;
    void mouseMoveEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE;
    void hoverMoveEvent(QGraphicsSceneHoverEvent *event) Q_DECL_OVERRIDE;

private:
    QPointF m_qPointBegin;
    QPointF m_qPointEnd;
    bool m_bStart;

signals:
    void sendLink(QRectF);
};

#endif // DRAWRECTROADITEM_H
